package o;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import com.huawei.gamebox.service.welfare.gift.bean.PlayerRoleInfo;
import java.util.ArrayList;
import java.util.List;
import o.exp.d;
import o.exp.j;

public class fch extends LinearLayout {
    private OnCheckedChangeListener ʻ = new OnCheckedChangeListener(this) {
        final /* synthetic */ fch ˎ;

        {
            this.ˎ = r1;
        }

        public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
            if (z) {
                this.ˎ.ʼ = compoundButton.getText().toString();
            }
        }
    };
    private String ʼ;
    private List<String> ʽ = new ArrayList();
    private Context ˊ;
    private List<PlayerRoleInfo> ˋ;
    private boolean ˎ;
    private fcm ˏ;
    private FrameLayout ॱ;
    private String ॱॱ;
    private View ᐝ;

    public fch(Context context) {
        super(context);
        this.ˊ = context;
    }

    public void ˊ(List<PlayerRoleInfo> list) {
        this.ˋ = list;
        this.ॱ = (FrameLayout) LayoutInflater.from(this.ˊ).inflate(j.ˊˋ, this, true).findViewById(d.ॱʽ);
        View ˎ = ˎ(this.ˊ);
        this.ᐝ = ॱ(this.ˊ);
        this.ॱ.addView(ˎ);
        this.ॱ.addView(this.ᐝ);
        ˎ.setVisibility(0);
        this.ᐝ.setVisibility(8);
        setFocusable(true);
        setFocusableInTouchMode(true);
        this.ˎ = true;
    }

    public void setListener(fcm o_fcm) {
        this.ˏ = o_fcm;
    }

    private View ˎ(Context context) {
        LayoutInflater from = LayoutInflater.from(context);
        LinearLayout linearLayout = (LinearLayout) from.inflate(j.ˋᐝ, null);
        RadioGroup radioGroup = (RadioGroup) linearLayout.findViewById(d.ॱᶥ);
        List arrayList = new ArrayList();
        LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2);
        if (CollectCheck.isEmpty(this.ˋ)) {
            Logger.e("GiftSelectRoleView", "playerList is empty");
        } else {
            boolean z = false;
            for (PlayerRoleInfo playerRoleInfo : this.ˋ) {
                boolean z2;
                if (ˎ(playerRoleInfo) && !arrayList.contains(playerRoleInfo.ॱ())) {
                    arrayList.add(playerRoleInfo.ॱ());
                    RadioButton radioButton = (RadioButton) from.inflate(j.ˋˋ, null);
                    radioButton.setText(playerRoleInfo.ॱ());
                    radioGroup.addView(radioButton, layoutParams);
                    radioButton.setOnCheckedChangeListener(new OnCheckedChangeListener(this) {
                        final /* synthetic */ fch ˊ;

                        {
                            this.ˊ = r1;
                        }

                        public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
                            if (z) {
                                this.ˊ.ॱॱ = compoundButton.getText().toString();
                            }
                        }
                    });
                    if (!z) {
                        radioGroup.check(radioButton.getId());
                        radioButton.setChecked(true);
                        z2 = true;
                        z = z2;
                    }
                }
                z2 = z;
                z = z2;
            }
        }
        return linearLayout;
    }

    private View ॱ(Context context) {
        return LayoutInflater.from(context).inflate(j.ˌ, null);
    }

    private void ˏ() {
        if (this.ᐝ == null) {
            Logger.e("GiftSelectRoleView", "selectRoleView == null");
        } else if (CollectCheck.isEmpty(this.ˋ)) {
            Logger.e("GiftSelectRoleView", "ListUtils.isEmpty(playerList)");
        } else {
            ˊ();
        }
    }

    private void ˊ() {
        ((TextView) this.ᐝ.findViewById(d.ͺˏ)).setText(this.ˊ.getString(exp$f.ʼˊ, new Object[]{this.ॱॱ}));
        RadioGroup radioGroup = (RadioGroup) this.ᐝ.findViewById(d.ˋʻ);
        this.ʽ.clear();
        LayoutInflater from = LayoutInflater.from(this.ˊ);
        boolean z = false;
        for (PlayerRoleInfo playerRoleInfo : this.ˋ) {
            boolean z2;
            if (ˋ(playerRoleInfo)) {
                this.ʽ.add(playerRoleInfo.ˏ());
                RadioButton radioButton = (RadioButton) from.inflate(j.ˋˋ, null);
                radioButton.setText(playerRoleInfo.ˏ());
                radioGroup.addView(radioButton, new LinearLayout.LayoutParams(-1, -2));
                radioButton.setOnCheckedChangeListener(this.ʻ);
                if (!z) {
                    radioGroup.check(radioButton.getId());
                    radioButton.setChecked(true);
                    z2 = true;
                    z = z2;
                }
            }
            z2 = z;
            z = z2;
        }
    }

    private boolean ˋ(PlayerRoleInfo playerRoleInfo) {
        return ˎ(playerRoleInfo) && playerRoleInfo.ॱ().equals(this.ॱॱ) && !this.ʽ.contains(playerRoleInfo.ˏ());
    }

    public void ॱ() {
        ˏ();
        if (this.ˎ) {
            if (this.ˏ != null) {
                this.ˏ.ˋ();
            }
            this.ˎ = false;
            ˎ(0, 1);
            return;
        }
        Logger.ˎ("GiftSelectRoleView", "has no next page");
    }

    private void ˎ(int i, int i2) {
        Animation translateAnimation = new TranslateAnimation(0.0f, (float) (-this.ॱ.getWidth()), 0.0f, 0.0f);
        translateAnimation.setDuration(250);
        translateAnimation.setFillAfter(true);
        this.ॱ.getChildAt(i).startAnimation(translateAnimation);
        this.ॱ.getChildAt(i).clearAnimation();
        this.ॱ.getChildAt(i).invalidate();
        this.ॱ.getChildAt(i).setVisibility(4);
        this.ॱ.getChildAt(i2).setVisibility(0);
        this.ॱ.getChildAt(i).setVisibility(8);
        translateAnimation = new TranslateAnimation((float) this.ॱ.getWidth(), 0.0f, 0.0f, 0.0f);
        translateAnimation.setDuration(250);
        translateAnimation.setFillAfter(true);
        this.ॱ.getChildAt(i2).startAnimation(translateAnimation);
    }

    private boolean ˎ(PlayerRoleInfo playerRoleInfo) {
        return (playerRoleInfo == null || TextUtils.isEmpty(playerRoleInfo.ॱ()) || TextUtils.isEmpty(playerRoleInfo.ˏ())) ? false : true;
    }

    public PlayerRoleInfo ˋ() {
        if (!CollectCheck.isEmpty(this.ˋ)) {
            for (PlayerRoleInfo playerRoleInfo : this.ˋ) {
                if (ˎ(playerRoleInfo) && playerRoleInfo.ॱ().equals(this.ॱॱ) && playerRoleInfo.ˏ().equals(this.ʼ)) {
                    return playerRoleInfo;
                }
            }
        }
        return null;
    }
}
